﻿#region Copyright and License
/*==============================================================================
 *  Copyright (c) cndotnet.org Corporation.  All rights reserved.
 * ===============================================================================
 * This code and information is provided "as is" without warranty of any kind,
 * either expressed or implied, including but not limited to the implied warranties
 * of merchantability and fitness for a particular purpose.
 * ===============================================================================
 * Licensed under the GNU General Public License (GPL) v2
 * http://www.cndotnet.org/ezsocio
 * ==============================================================================*/
#endregion

#region Using

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CNdotnet.Ezsocio.TemplateEngine;

#endregion

namespace CNdotnet.Ezsocio.EmailService
{
    /// <summary>
    /// The extension methods class of the mail contract
    /// </summary>
    public static class MailContractExtension
    {
        /// <summary>
        /// Converts to entity.
        /// </summary>
        /// <param name="mail">The mail.</param>
        /// <returns></returns>
        public static MailWaitItem ConvertToEntity(this MailContract mail)
        {
            MailWaitItem waitItem = new MailWaitItem();
            waitItem.Subject = mail.Subject;
            waitItem.Recipient = mail.Recipient;
            waitItem.Priority = (short)mail.Priority;
            waitItem.CreateDate = mail.CreateDate;
            waitItem.Content = TemplateService.Generate(mail.Content);
            waitItem.MailType = (short)mail.Category;
            waitItem.SentDate = mail.SentDate;
            waitItem.Retries = mail.Retries;

            return waitItem;
        }
    }
}
